﻿// -----------------------------------------------------------------------
// <copyright file="Fee.cs" company="VDC-IT" author="LTDUC">
//      Copyright (c) VDC-IT. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace VDC.VONE.ENTITIES
{
    using System;
    using System.Data.SqlClient;
    using AdCom.Utility;
    using VDC.COMMON;
    
    /// <summary>
    /// Class Fee
    /// </summary>
    public class Fee
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Fee" /> class
        /// </summary>
        public Fee()
        {
            this.FeesId = 0;
            this.ProfileId = 0;
            this.ChargeUserId = 0;
            this.ChargeData = null;
            this.Fees = 0;
            this.Note = string.Empty;
        }
                
        /// <summary>
        /// Gets or sets FeesId
        /// </summary>
        public int FeesId { get; set; }

        /// <summary>
        /// Gets or sets ProfileId
        /// </summary>
        public int ProfileId { get; set; }

        /// <summary>
        /// Gets or sets ChargeUserId
        /// </summary>
        public int ChargeUserId { get; set; }

        /// <summary>
        /// Gets or sets ChargeData
        /// </summary>
        public DateTime? ChargeData { get; set; }

        /// <summary>
        /// Gets or sets Fee
        /// </summary>
        public decimal Fees { get; set; }

        /// <summary>
        /// Gets or sets Note
        /// </summary>
        public string Note { get; set; }

        /// <summary>
        /// Gets Profile
        /// </summary>
        public Profile Profile
        {
            get
            {
                try
                {
                    Profile profile = null;
                    SqlDataReader reader = SqlDataHelper.ExecuteReader(string.Format(Constants.StorepProcedure.VOneProfileGetById, this.ProfileId));

                    while (reader.Read())
                    {
                        profile = new Profile();

                        if (!reader.IsDBNull(0))
                        {
                            profile.ProfileId = reader.GetInt32(0);
                        }

                        if (!reader.IsDBNull(1))
                        {
                            profile.ProfileStatusId = reader.GetInt32(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            profile.ProfileTypeId = reader.GetInt32(2);
                        }

                        if (!reader.IsDBNull(3))
                        {
                            profile.LevelId = reader.GetInt16(3);
                        }

                        if (!reader.IsDBNull(4))
                        {
                            profile.StorageLocationProfileListId = reader.GetInt32(4);
                        }

                        if (!reader.IsDBNull(5))
                        {
                            profile.CreateUserId = reader.GetInt32(5);
                        }

                        if (!reader.IsDBNull(6))
                        {
                            profile.Code = reader.GetString(6);
                        }

                        if (!reader.IsDBNull(7))
                        {
                            profile.Name = reader.GetString(7);
                        }

                        if (!reader.IsDBNull(8))
                        {
                            profile.SmsGet = reader.GetString(8);
                        }

                        if (!reader.IsDBNull(9))
                        {
                            profile.Email = reader.GetString(9);
                        }

                        if (!reader.IsDBNull(10))
                        {
                            profile.CreateDate = reader.GetDateTime(10);
                        }

                        if (!reader.IsDBNull(11))
                        {
                            profile.ReceivingDate = reader.GetDateTime(11);
                        }

                        if (!reader.IsDBNull(12))
                        {
                            profile.AppointmentDate = reader.GetDateTime(12);
                        }

                        if (!reader.IsDBNull(13))
                        {
                            profile.Object = reader.GetBoolean(13);
                        }

                        if (!reader.IsDBNull(14))
                        {
                            profile.SettlementDate = reader.GetDateTime(14);
                        }

                        if (!reader.IsDBNull(15))
                        {
                            profile.Notes = reader.GetString(15);
                        }

                        if (!reader.IsDBNull(16))
                        {
                            profile.Attachments = reader.GetString(16);
                        }

                        if (!reader.IsDBNull(17))
                        {
                            profile.ContentWork = reader.GetString(17);
                        }

                        if (!reader.IsDBNull(18))
                        {
                            profile.IsDelete = reader.GetBoolean(18);
                        }

                        if (!reader.IsDBNull(19))
                        {
                            profile.OrganName = reader.GetString(19);
                        }

                        if (!reader.IsDBNull(20))
                        {
                            profile.Address = reader.GetString(20);
                        }

                        if (!reader.IsDBNull(21))
                        {
                            profile.Phone = reader.GetString(21);
                        }
                    }

                    reader.Close();
                    reader.Dispose();

                    return profile;
                }
                catch (SqlException ex)
                {
                    LogHelper.Instance.WriteError(ex);
                    throw new Exception(ex.ToString());
                }
            }
        }
    }
}
